package com.lib.model.dao;

import java.sql.SQLException;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.lib.model.dto.ReservationDto;

public class BookReservationDao extends SqlMapClientDaoSupport implements IBookReservationDao{

	@Override
	public boolean reservation(ReservationDto rDto) {
		int count = 0;
		try {
			int cc  = (Integer)getSqlMapClientTemplate().queryForObject("BookReservation.checkReservation",rDto);
			if(cc <= 0){
				getSqlMapClientTemplate().insert("BookReservation.reservationBookInsert",rDto);
				getSqlMapClientTemplate().update("BookReservation.reservationBookUpdate",rDto);
				count = 1;
			}else{
				count = -1;
			}
		} catch (Exception e) {

			count = -1;
		}
		
		return count>0?true:false;
	}

}
